package Gui;

import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JTextField;
import javax.swing.border.EmptyBorder;

@SuppressWarnings("serial")
public class GuessFrame extends JFrame {

	private JPanel contentPane;
	private JTextField textField;

	/**
	 * Create the frame.
	 */
	public GuessFrame() {
		setTitle("Wheel Of Fortune");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 310, 180);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);

		textField = new JTextField();
		textField.setColumns(10);
		textField.setBounds(22, 47, 259, 20);
		contentPane.add(textField);

		JButton btnGuess = new JButton("Guess!");
		btnGuess.setFont(new Font("Tahoma", Font.PLAIN, 15));

		setDefaultCloseOperation(HIDE_ON_CLOSE);

		btnGuess.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				if (textField.getText().trim().equals("")){
					JOptionPane.showMessageDialog(null, "Please enter a guess");
				}
				else{
					lettersPanel.btnContinue.setEnabled(false);
					lettersPanel.onGuess();
					lettersPanel.whopressed.guessExp(textField.getText());
					textField.setText("");
					textField.setEnabled(false);
					lettersPanel.onGuess();
				}
				setVisible(false);
			}
		});
		btnGuess.setBounds(174, 90, 107, 41);
		contentPane.add(btnGuess);

		JLabel lblYourGuess = new JLabel("Your Guess");
		lblYourGuess.setFont(new Font("Tahoma", Font.PLAIN, 15));
		lblYourGuess.setBounds(104, 11, 85, 25);
		contentPane.add(lblYourGuess);

		JButton btnCancel = new JButton("Cancel");
		btnCancel.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				setVisible(false);
			}
		});
		btnCancel.setFont(new Font("Tahoma", Font.PLAIN, 15));
		btnCancel.setBounds(22, 90, 107, 41);
		contentPane.add(btnCancel);
	}
}
